package my.graduation.controller.admin;

import my.graduation.dto.PatientInfoDto;
import my.graduation.result.Result;
import my.graduation.service.PatientService;
import my.graduation.vo.PatientVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: RavenLyn
 * @Date: 2024-12-11
 */
@RestController
@RequestMapping("/admin/patient")
public class AdmPatientController {

    @Autowired
    private PatientService patientService;
    /**
     * 获取患者信息
     * @return
     */
    @GetMapping
    public Result<List<PatientVO>> list(){
        return patientService.getList();
    }

    /**
     * 条件获取患者信息
     * @param dto
     * @return
     */
    @PostMapping("/con")
    public Result<List<PatientVO>> list(@RequestBody PatientInfoDto dto){
        return patientService.getListByCon(dto);
    }

    /**
     * 新增患者信息
     * @return
     */
    @PostMapping
    public Result add(@RequestBody PatientInfoDto dto){
        return patientService.add(dto);
    }

    /**
     * 修改患者信息
     * @return
     */
    @PutMapping
    public Result update(@RequestBody PatientInfoDto dto){
        return patientService.update(dto);
    }

    /**
     * 删除患者信息
     * @return
     */
    @DeleteMapping
    public Result delete(@RequestBody PatientInfoDto dto){
        return patientService.delete(dto);
    }
}
